import { instance } from '../request'

const request = instance

/**
 * 创建项目分组
 * @param name 项目分组名称
 * @param description 项目分组描述
 * @param projectId 项目id
 * @returns
 */
export const addProjectGroupApi = (
  name: string,
  description: string,
  projectId: string
): PromiseRes =>
  request.post('/projectGroup/add', { name, description, projectId })

/**
 *修改项目分组
 * @param id 项目分组id
 * @param name 项目组名称
 * @param description 项目组描述
 * @returns
 */
export const updateProjectGroupApi = (
  id: string,
  name: string,
  description: string
): PromiseRes => request.post('/projectGroup/update', { id, name, description })

/**
 *删除项目分组
 * @param id 项目分组id
 * @returns
 */
export const deleteProjectGroupApi = (id: string): PromiseRes =>
  request.post(`/projectGroup/delete?projectGroupId=${id}`)

/**
 * 获取项目分组列表
 *   @param projectId 项目分组id
 * @returns
 */
export const getProjectGroupApi = (
  projectId: string
): PromiseRes<ProjectGroupItf[]> =>
  request.get(`/projectGroup/get?projectId=${projectId}`)
